<?php
$php_arr=explode("/",$_SERVER["PHP_SELF"]);
$php_arr_rev=array_reverse($php_arr);
$dirroot = explode($php_arr_rev[0],$_SERVER['SCRIPT_FILENAME']);
$dir=$dirroot[0];

$file=$_REQUEST['filename'];

$filenamearr=explode("/",$_REQUEST['filename']);
$filename=$filenamearr[count($filenamearr)-1];

if(strstr($filename,"@"))
{
    $filenamearr=array();
    $filenamearr=explode("@",$filename);
    $filename=$filenamearr[count($filenamearr)-1];
}

if ((isset($file))&&(file_exists($dir.$file))) {
       header("Content-type: application/force-download");
       header('Content-Disposition: inline; filename="' . $dir.$file . '"');
       header("Content-Transfer-Encoding: Binary");
       header("Content-length: ".filesize($dir.$file));
       header('Content-Type: application/octet-stream');
       header('Content-Disposition: attachment; filename="' . $filename . '"');
       readfile("$dir$file");
    } else {
       echo "<font color='red'><b>Sorry. We could not download file.<br> Error: $dir$file</font>";
    }
?>